const static = require('koa-static');

module.exports = function(router, options){

    // 配置默认时间
    options = options || {};

    options.image = options.image || 30,
    options.script = options.script || 1,
    options.html = options.html || 30,
    options.order = options.order || 7,

    // 分配请求的不同缓存时间
    router.all(/((\.jpg)|(\.png)|(\.gif))$/i, static('./static',{
        maxage: options.image * 86400 * 1000
    }))

    router.all(/((\.js)|(\.jsx))$/i, static('./static',{
        maxage: options.script * 86400 * 1000
    }))

    router.all(/((\.html)|(\.htm))$/i, static('./static',{
        maxage: options.html * 86400 * 1000
    }))

    router.all('*', static('./static',{
        maxage: options.order * 86400 * 1000
    }))

}


